<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui">

<ui:composition template="/dndTemplate.xhtml">



	<ui:define name="main">
		
			<table border="1" width="100%">
				<tr>
					<td colspan="2">
					<h:form >
					<p:growl id="messages" showDetail="true" />
					Name:<p:inputText value="#{adminDecksBean.searchDeckName}" id="searchDeckName" /> 
									Description:<p:inputText value="#{adminDecksBean.searchDeckDesc}" id="searchDeckDesc" /> 
									<p:commandButton value="Search" action="#{adminDecksBean.searchDeck()}" update=":decks">
						</p:commandButton>
					</h:form>
					</td>
				</tr>

				<tr>
					<td width="300" height="500" valign="top">
					
						<p:dataList value="#{adminDecksBean.decks}" var="deck" id="decks" type="definition" paginator="true" rows="15">
							<h:form >
							<p:growl id="messages" showDetail="true" />
	
								<p:commandButton icon="ui-icon-search" update=":deckForm :cards :allCards" title="View Detail" action="#{myCardsBean.selectDeck(deck)}" />
								<p:graphicImage value="#{deck.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40" height="50" />
							#{deck.name}
							</h:form>
						
						</p:dataList>
					
					</td>
					<td valign="top">
						<table>
							
							<tr>
								<td valign="top">
								<h:form id="deckForm" rendered="#{myCardsBean.selectedDeck!=null}">
								<p:growl id="messages" showDetail="true" />
								Name:<p:inputText value="#{myCardsBean.selectedDeck.name}" />
										<br />
								Picture: <p:inputText value="#{myCardsBean.selectedDeck.pictureURL}" />
										<p:graphicImage value="#{myCardsBean.selectedDeck.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="240" height="300" />
										<br />
								Description:<p:inputText value="#{myCardsBean.selectedDeck.description}" />
										<br />
										<p:commandButton value="Save" action="#{adminDecksBean.searchDeck()}" update=":decks :deckForm">
											<f:actionListener binding="#{myCardsBean.updateDeck()}" />
										</p:commandButton>
										<p:commandButton value="Add" action="#{adminDecksBean.searchDeck()}" update=":decks :deckForm">
											<f:actionListener binding="#{myCardsBean.createDeck()}" />
										</p:commandButton>
										<p:commandButton value="Remove" action="#{adminDecksBean.searchDeck()}" update=":decks :deckForm">
											<f:actionListener binding="#{myCardsBean.deleteDeck()}" />
										</p:commandButton>
										
								</h:form>
								<h:form enctype="multipart/form-data">
											<p:messages showDetail="true"/>  
											<p:fileUpload value="#{myCardsBean.uploadedFile}" mode="simple" />
											<p:commandButton value="submit" ajax="false"  action="#{adminDecksBean.searchDeck()}" update=":decks :deckForm" >
												<f:actionListener binding="#{myCardsBean.uploadCard(myCardsBean.selectedDeck.id)}" />
											</p:commandButton>
											
								</h:form>
								</td>
								<td height="300" valign="top">
										<h:form >
										<p:growl id="messages" showDetail="true" />
										Name:<p:inputText value="#{myCardsBean.searchCardName}" /> 
										Description:<p:inputText value="#{myCardsBean.searchCardDesc}" /> 
										<p:commandButton value="Search" action="#{myCardsBean.searchCardInDeck(myCardsBean.cards)}" update=":cards"></p:commandButton>
										</h:form>
										<p:dataList id="cards" value="#{myCardsBean.cards}" var="card" type="definition" paginator="true" rows="5">
										<h:form >
											<p:growl id="messages" showDetail="true" />
											<h:outputText value="#{card.name}" />
											<p:graphicImage value="#{card.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40" height="50" />
											<br />
											<h:outputText value="#{card.description}" />
											<br />
											<p:commandButton icon="ui-icon-search" title="View" action="#{myCardsBean.selectCard(card)}" update=":cardForm" />
										</h:form>
									</p:dataList></td>

							</tr>


							<tr>
								<td valign="top">
									<h:form id="cardForm">
									<p:growl id="messages" showDetail="true" />
									Name:<h:outputText value="#{myCardsBean.selectedCard.name}" /> <br /> 
									<p:graphicImage value="#{myCardsBean.selectedCard.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="240" height="300" /> <br /> 
									Picture URL:<h:outputText value="#{myCardsBean.selectedCard.pictureURL}" /> <br /> 
									Description:<h:outputText value="#{myCardsBean.selectedCard.description}" />
									<br /> 
									Rating: <p:rating cancel="false" value="#{myCardsBean.selectedCardRate}" readonly="true" id="rate">
									</p:rating> (<h:outputText value="#{myCardsBean.selectedCard.rateCount}" id="ratingCount" />) <br /> 
									<p:commandButton value="Add" action="#{myCardsBean.addCardtoDeck()}" update=":cards" /> 
									<p:commandButton value="Remove" action="#{myCardsBean.removeCardfromDeck()}" update=":cards" />
									</h:form>

								</td>
								<td height="300" valign="top">
										<h:form>
										<p:growl id="messages" showDetail="true" />  
											Name:<p:inputText value="#{myCardsBean.searchCardName}" id="searchCardName" />
											Description:<p:inputText value="#{myCardsBean.searchCardDesc}" id="searchCardDesc" />
											<p:commandButton value="Search" action="#{myCardsBean.searchCard(myCardsBean.allCards)}" update=":allCards"></p:commandButton>
										</h:form> 
										<p:dataList id="allCards" value="#{myCardsBean.allCards}" var="card" type="definition" paginator="true" rows="10">
										<h:form >
											<p:growl id="messages" showDetail="true" />
											<h:outputText value="#{card.name}" />
											<p:graphicImage value="#{card.pictureURL}&amp;userName=#{myCardsBean.userName}&amp;sessionID=#{myCardsBean.sessionID}" width="40" height="50" />
											<br />
											
											<p:commandButton icon="ui-icon-search" title="View" action="#{myCardsBean.selectCard(card)}" update=":cardForm" />
										</h:form>
								</p:dataList></td>

							</tr>

						</table>
					</td>
				</tr>
			</table>


	</ui:define>

</ui:composition>

</html>
